<?php
class TwitterFilter{

	private $json_output = array();

	public function __construct(){
		$jsonurl = "http://search.twitter.com/search.json?include_entities=true&q=%23hackearthquakes";
		$json = file_get_contents($jsonurl,0,null,null);
		$tmp = json_decode($json, true);
		$json_arr = array();
		foreach($tmp['results'] as $key => $value){
			$geo = $value['geo']["coordinates"];
			if(sizeof($geo) > 1){
				$expanded_url = $value['entities']['urls'][0]["expanded_url"];
				preg_match('/http:\/\/twitpic.com\/(.+)/i', $expanded_url, $pict_id);
				if(!empty($pict_id)){
					$tmp_arr = array('img'=>'http://twitpic.com/show/thumb/'.$pict_id[1], 'tweet_account'=>$value['from_user'], 'lat'=>$geo[0], 'lng'=>$geo[1], 'id'=>(string)$value['id_str']);
					array_push($this->json_output, $tmp_arr);
				}
			}
		}
	}

	public function getTitles(){
		$all_titles = "";
	}

	/**
	 * 全フィルタされたデータを作る
	 */
	public function getAllTweet(){
		return array('entry' => $this->json_output);
	}
}